package chapter67;

/*
 * 动物类
 */
public abstract class Animal {
	//动物叫的方法
	public abstract void cry();
}

class Dogs extends Animal{
	public void cry(){
		System.out.println("狗叫：汪汪汪");
	}
}

class Cat extends Animal{
	public void cry(){
		System.out.println("猫叫：喵喵喵");
	}
}

class Duck extends Animal{
	public void cry(){
		System.out.println("鸭子叫：嘎嘎嘎");
	}
}

/*
 * 主人类
 */
class Masters{
	//赠送给别人动物
	public Animal domateAnimal(String type){
		Animal animal = null;
		if (type.equals("dog")){
			animal = new Dogs();
		}else if(type.equals("cat")){
			animal = new Cat();
		}else{
			animal = new Duck();
		}
		return animal;
	}
}

